#!/usr/bin/python
# -*- coding: UTF-8 -*-

import MySQLdb


# 打开数据库连接
db=MySQLdb.connect("localhost","root","123","ed_db", charset='utf8')

cu = db.cursor();

sql = """
 INSERT INTO `employee` 
    (`FIRST_NAME`, 
    `LAST_NAME`, 
    `AGE`, 
    `SEX`, 
    `INCOME`
    )
    VALUES
    ('A', 
    'B', 
    1, 
    '男', 
    1.5
    );
"""

try:
    
 
 a=cu.execute(sql)
 db.commit()
 
 if a !=0: 
    print "插入成功"
 else:
    print "插入失败" 

    
except:
    print "插入异常" 
    db.rollback()

db.close()